﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace peonwar
{
    public class Sprite
    {
        // ---CONSTRUCTORS---
        // Construire le sprite pour donner direct la position
        // en Vector2
        public Sprite()
        {
        }

        public Sprite(Vector2 pos)
        {
            this.Position = pos;
        }

        public Sprite(float x, float y, Texture2D texture)
        {
            this.Position = new Vector2(x, y);
            this.Texture = texture;
        }

        public Sprite(float x, float y, Texture2D texture, Color color)
        {
            this.Position = new Vector2(x, y);
            this.Texture = texture;
            this.SpriteColor = color;
        }

        // ---PROPERTIES---
        // Texture du sprite
        public Texture2D Texture;
        public byte Fade = 255;

        // Position du sprite/de l'unite
        public Vector2 Position { get; set; }

        // Effet pour prendre le sprite miroir (en fonction de l'equipe)
        public SpriteEffects Effect;

        // Couleur du sprite
        protected Color SpriteColor = Color.White;

        // ---METHODES---
        public virtual void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            int c = 0;
            if (camera != null)
                c = camera.Position;
           // spriteBatch.Draw(Texture, new Vector2(Position.X - (Texture.Width / 2) - c, Position.Y - Texture.Height / 2), Color.White);
            spriteBatch.Draw(Texture, new Rectangle((int)Position.X - (Texture.Width / 2) - c, (int)Position.Y - Texture.Height / 2, Texture.Width, Texture.Height), null, SpriteColor, 0f, Vector2.Zero, Effect, 0f);
        }
    }
}